<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<jsp:useBean id="now" class="java.util.Date" scope="page"/>

<html>
<head>
    <title>后台登录</title>
    <meta name="Keywords" content="后台登录">
    <meta name="description" content="后台登录">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="keywords"
          content="Login form web template, Sign up Web Templates, Flat Web Templates, Login signup Responsive web template, Smartphone Compatible web template, free webdesigns for Nokia, Samsung, LG, SonyErricsson, Motorola web design"/>
    <%-- <link href='http://fonts.useso.com/css?family=Roboto:500,900italic,900,400italic,100,700italic,300,700,500italic,100italic,300italic,400' rel='stylesheet' type='text/css'>
     <link href='http://fonts.useso.com/css?family=Droid+Serif:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
     --%>
    <link href="/Components/loginstyle.css" rel="stylesheet" type="text/css" media="all"/>
</head>
<body>

<%--用户名：<input type="text" name="userName" id="userName"/>
密码：<input type="password" name="password" id="password"/>--%>
<%--<button type="button" onclick="javascript:doSubmitForm()">登录</button>--%>
</form>

<div class="login">
    <h2>后台登录</h2>
    <form action="/admin/login" method="post">
        <div class="login-top">
            <h1>LOGIN IN</h1>
            <form>
                <input type="text" value="用户名" name="userName" id="userName" onfocus="this.value = '';"
                       onblur="if (this.value == '') {this.value = '用户名';}">
                <input type="password" name="password" id="password" value=111111" onfocus="this.value = '';"
                       onblur="if (this.value == '') {this.value = '密码';}">
            </form>
            <div class="forgot">
                <a href="#">忘记密码请联系管理员</a>
                <input type="button" value="Login" onclick="javascript:doSubmitForm()">
            </div>
        </div>
        <div class="login-bottom">
            <h3>本站版权由 &nbsp;<a href="#">dnf-free.com</a>&nbsp 持有</h3>
        </div>
    </form>
</div>
<%-- <div class="copyright">
     <p>Copyright &copy; 2015.Company name All rights reserved.<a target="_blank" href="http://www.cssmoban.com/">&#x7F51;&#x9875;&#x6A21;&#x677F;</a> - More Templates <a href="http://www.cssmoban.com/" target="_blank" title="模板之家">模板之家</a></p>
 </div>--%>
</body>
</html>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script type="text/javascript">
    function doSubmitForm() {
        $.ajax({
            url: "/admin/login",
            type: "post",
            data: {
                userName: $("#userName").val(),
                password: $("#password").val()
            },
            success: function (data) {
                if (data.succ) {
                    alert(data.msg);
                    window.location.href = "admin/manager"
                } else {
                    alert(data.msg);
                }
            },
            error: function (e) {
                alert("服务器运行出错，请联系管理员！！");
                console.log(e);
            }

        })
    }

</script>